/*!
 * Copyright 2019 WeBank
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

 @import "normalize";
 @import "@dataspherestudio/shared/common/style/variables.scss";
 $title-color : #464c5b;
 $text-color : #657180;
 $sub-text-color : #999;
 $dark-color : #333;
 $toool-button-color: rgba(0,0,0,0.65);

 // Border color
 $border-color-base :#DEE4EC; // outside
 $border-color-split : #e3e8ee; // inside


 // Background color
 $background-color-base : #F8F9FC;
 $hover-color : #f3f3f3;
 $tooltip-color : #fff;

 // Shadow
 $shadow-color : rgba(0, 0, 0, .2);
 $shadow-1-up : 0 -1px 6px $shadow-color;
 $shadow-1-down : 0 1px 6px $shadow-color;
 $shadow-1-left : -1px 0 6px $shadow-color;
 $shadow-1-right : 1px 0 6px $shadow-color;
 $shadow-2 : 0 2px 8px $shadow-color;
 $box-shadow-base : $shadow-1-down;

 $mask-color: rgba(55, 55, 55, .6);

 ::-webkit-scrollbar-thumb {
   @include bg-color(#cdcdcd, #474E5D);
 }
 .designer {
   position: relative;
   width: 100%;
   height: 100%;
   overflow: hidden;
   user-select: none;
   outline: none;
   font-size: 12px;
   @include font-color($text-color, $dark-workflow-font-color);
   @include bg-color(#fff, $dark-workflow-bg-color);

   * {
     box-sizing: border-box;
     -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
   }

   *:before,
   *:after {
     box-sizing: border-box;
   }

   input,
   textarea,
   .designer-button {
     height: 26px;
     line-height: 26px;
     padding: 0 8px;
     border: 1px solid $border-color-base;
     @include border-color($border-color-base, rgba(255, 255, 255, 0.2));
     outline: 0;
     font-size: 12px;
     border-radius: 2px;
     @include font-color($text-color, $dark-workflow-font-color);
     @include bg-color($tooltip-color, $dark-workflow-bg-color);
   }

   .designer-button {
     padding: 0 12px;
   }

   .designer-toolbar {
     position: absolute;
     left: 0;
     top: 0;
     width: 100%;
     height: 36px;
     padding-left: 10px;
     @include bg-color($background-color-base, $dark-workflow-bg-color);
     border-bottom: 1px solid $border-color-base;
     @include border-color($border-color-base, $dark-base-color);

     .icon {
       display: inline-block;
       vertical-align: text-top;

       @include font-color($dark-color, rgba(255,255,255,0.65));
       text-align: center;
     }

     .text {
       vertical-align: text-top;
     }

     .button {
       float: left;
       margin: 6px 0px 6px 0;
       padding: 0;
       height: 18px;
       // width: 54px;
       text-align: left;
       border: 1px solid transparent;
       border-radius: 2px;
       position: relative;
       cursor: pointer;
       line-height: 18px;
       @include font-color($toool-button-color, rgba(255,255,255,0.65));
       .icon {
         margin-right: 8px;
         @include font-color($toool-button-color, rgba(255,255,255,0.65));
         font-size: 16px;
       }
       .stop {
         color: red;
       }
       span {
         vertical-align: middle;
         @include font-color($toool-button-color, rgba(255,255,255,0.65));
         font-size: 14px;
       }
     }

     .long-button {
       min-width: 60px;
     }

     .devider {
       float: left;
       border-left: 1px solid $border-color-split;
       height: 16px;
       margin: 8px 15px;
     }
   }

   &.show-toolbar {

     .designer-shape,
     .designer-viewport,
     .right-draw,
     .designer-control {
       top: 36px;
     }
   }

   .designer-shape {
     position: absolute;
     left: 0;
     top: 0;
     bottom: 0;
     width: 180px;
     overflow-x: hidden;
     overflow-y: auto;
     @include bg-color($background-color-base, $dark-workflow-bg-color);
     border-right: 1px solid $border-color-base;
     @include border-color($border-color-base, $dark-base-color);
     transition: all .3s;

     .shape-head {
       display: flex;
       padding: 0 10px 0 20px;
       height: 36px;
       align-items: center;
       justify-content: space-between;
       // border-top: 1px solid #DEE4EC;
       border-bottom: 1px solid #DEE4EC;
       @include border-color(#DEE4EC, $dark-base-color);
       .head-title {
         font-size: 14px;
         @include font-color(#333, $dark-workflow-font-color);
       }
       .head-btn {
         width: 32px;
         height: 32px;
         line-height: 32px;
         text-align: center;
         font-size: 20px;
         cursor: pointer;
         &:hover {
           @include font-color(#000, #fff);
         }
       }
     }

     .shape-search {
       display: block;
       width: 80%;
       margin: 10px auto;
     }

     .shape-container {
       margin-top: 1px;
       // border-bottom: 1px solid $border-color-split;
       @include border-color($border-color-split, $dark-workflow-bg-color);

       &.top {
         border-top: 1px solid $border-color-split;
         @include border-color($border-color-split, $dark-workflow-bg-color);
       }

       .icon {
         height: 14px;
         width: 14px;
       }

       .shape-title {
         position: relative;
         margin: 0px;
         height: 30px;
         line-height: 30px;
         padding-left: 20px;
         white-space: nowrap;
         text-overflow: ellipsis;
         overflow: hidden;
         cursor: pointer;
         @include font-color($title-color, $dark-workflow-font-color);
         font-weight: 400;
         font-size: 14px;
         @include bg-color(#EDF1F6, #252A35);
         .icon {
           font-size: 16px;
         }
       }
     }

     .shape-box {
       display: flex;
       align-items: center;
       height: 34px;
       line-height: 34px;
       padding: 0 10px 0 20px;
       cursor: pointer;
       &:hover {
         @include bg-color(#EDF1F6, #252A35);
       }
     }
     .shape-title-txt {
       flex: 1;
       padding: 0 6px;
       font-size: 14px;
       line-height: 36px;
       text-overflow: ellipsis;
       overflow: hidden;
     }

     .shape-box-img {
       display: inline-block;
       width: 22px;
       height: 22px;
       user-select: none;
       pointer-events: none;
     }

     .shape-box-draging {
       position: absolute;
       text-align: center;
       border-radius: 4px;
       opacity: 0.5;
       cursor: all-scroll;
     }
   }
   .shape-fold {
     transform: translateX(-100%);
   }
   .designer-expand {
     z-index: 2;
     position: absolute;
     top: 40px;
     left: 4px;
     width: 34px;
     height: 34px;
     line-height: 34px;
     text-align: center;
     font-size: 20px;
     @include bg-color(#F8F9FC, #2A303C);
     border: 1px solid #DEE4EC;
     @include border-color(#DEE4EC, #2A303C);
     cursor: pointer;
     &:hover {
       @include font-color(#000, #fff);
     }
   }

   .designer-viewport {
     position: absolute;
     left: 180px;
     top: 0;
     right: 0;
     bottom: 0;
     overflow: auto;
     transition: all .3s;
     @include bg-color(#fff, $dark-base-color)
   }
   .designer-viewport-fold {
     left: 0;
   }

   .snap-line {
     position: absolute;
     z-index: 4;
     background: #6eb1eb;
   }

   .node-box {
     position: absolute;
     left: 0;
     top: 0;
     z-index: 2;
     @include bg-color(#fff, $dark-workflow-bg-color);
     cursor: move;

     &:hover {
       .node-anchor {
         display: block;
       }
     }

     .node-anchor {
       display: none;
       position: absolute;
       z-index: 1;
       @include border-color(#ff9900, #4077C9);
       border-style: solid;
       border-width: 1px;
       @include bg-color($light-base-color, $dark-base-color);
       cursor: crosshair;
     }

     .node-box-bg {
       user-select: none;
       pointer-events: none;
     }

     .node-box-content {
       position: absolute;
       left: 25px;
       top: 0;
       bottom: 0;
       right: 5px;
       z-index: 0;
       overflow: hidden;
       text-overflow: ellipsis;
       white-space: nowrap;
     }
   }

   .linker-box {
     position: absolute;
     z-index: 1;
     display: none;
   }

   .drag-linker-box {
     cursor: crosshair;
   }

   .right-draw {
     position: absolute;
     top: 0;
     right: 0;
     bottom: 0;
     width: 400px;
     border-left: 1px solid $border-color-base;
     border-right: 1px solid $border-color-base;
     box-shadow: -6px 0 6px -6px $shadow-color;
     overflow: auto;
     z-index: 1100;
     color: $text-color;
     background: #fff;

     .icon {
       width: 14px;
       height: 14px;
       cursor: pointer;
     }

     .right-draw-title {
       padding: 0 20px;
       height: 36px;
       line-height: 36px;
       color: $title-color;
       border-bottom: 1px solid $border-color-split;
       font-size: 12px;
       font-weight: 500;

       .icon {
         width: 16px;
         height: 16px;
         float: right;
         color: #464c5b;
         margin-top: 6px;
       }
     }

     .right-draw-content {
       padding: 0 20px;
     }

     .row {
       margin: 16px 0;
       font-size: 0;

       .row-name {
         padding-right: 20px;
         display: inline-block;
         vertical-align: middle;
         width: 100px;
         text-align: right;
         font-size: 12px;
       }

       .half {
         display: inline-block;
         width: 50%;
         vertical-align: middle;
         font-size: 12px;
         text-align: center;
       }

       .row-input {
         vertical-align: middle;
         width: 200px;
       }

       .row-button {
         cursor: pointer;

         &:hover {
           background: $hover-color;
         }
       }

       textarea {
         min-height: 52px;
       }
     }
   }

   .baseinfo {
     .row-button {
       margin-left: 100px;
     }
   }

   .paraminfo {
     .row-button {
       margin-left: 155px;
     }
   }

   .designer-control {
     position: absolute;
     top: 0;
     right: 14px;
     width: 36px;
     z-index: 500;

     .designer-control-header {
       @include bg-color(#5c5c5c, #474E5D);
       height: 8px;
       border-left: 1px solid #5c5c5c;
       border-right: 1px solid #5c5c5c;
       border-top: 1px solid #646464;
       border-bottom: 1px solid #000;
       @include border-color(#5c5c5c, #474E5D);
     }

     .designer-control-buttons {
       @include bg-color(#fff, #2A303C);
       padding: 10px 0px 10px;
       border-left: 1px solid #d7dde4;
       border-right: 1px solid #d7dde4;
       border-bottom: 1px solid #d7dde4;
       @include border-color(#d7dde4, #2A303C);
       overflow: visible;
     }

     .designer-control-button {
       position: relative;
       margin: 5px 5px 5px 5px;
       height: 24px;
       line-height: 24px;
       text-align: center;
       font-size: 18px;
       cursor: pointer;
     }

     .designer-control-dialog {
       position: absolute;
       top: 50px;
       right: 40px;
       width: max-content;
       height: auto;
       min-width: 220px;
      //  height: 120px;
       @include bg-color(#fff, $dark-base-color);
       border: 1px solid rgba(0, 0, 0, 0.5);
       box-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);

       .line-type {
         width: 100%;
         height: 40px;
         display: flex;
         justify-content: center;

         input,
         label {
           margin: 0 3px;
           align-self: center;
           cursor: pointer;
         }
       }

       .node-width-container {
         width: 100%;
         height: 40px;
         text-align: center;
       }

       .operations {
         width: 100%;
         height: 40px;
         text-align: center;
         .comfirm-btn {
            background-color: $primary-color;
            color: #fff;
          }
         .format,
         .dialog-btn,
         .cancel {
           margin-left: 5px;
           display: inline-block;
           width: 50px;
           height: 24px;
           line-height: 24px;
           border: 1px solid #d7dde4;
           cursor: pointer;
           border-radius: 4px;
           &:hover {
             border: 1px solid black;
           }
         }
       }
     }

     .designer-control-dialog.reset {
       top: 120px;
       height: 90px;

       .hint {
         margin-top: 5px;
         width: 100%;
         height: 40px;
         line-height: 40px;
         text-align: center;
       }
     }
     .designer-control-dialog.search {
       top: 0px;
       width: 400px;
       height: 230px;
       padding: 10px;
       @include bg-color(#fff, $dark-base-color);
       .node-list-container {
         height: 180px;
         overflow: auto;
         padding-top: 5px;
       }
       .close {
         padding-left: 10px;
         cursor: pointer;
         &:hover {
           color: #2d8cf0
         }
       }
       input {
         flex: 1;
       }
       .search-head {
         margin-bottom: 5px;
         display: flex;
         align-items: center;
       }
       .node-item {
         height: 28px;
         line-height: 28px;
         border-top: 1px solid #e3e8ee;
         padding: 0 5px;
         overflow: hidden;
         text-overflow: ellipsis;
         cursor: pointer;
         &:hover {
           background: $hover-color;
           color: #2d8cf0
         }
       }
       .no-data {
         padding-top: 20px;
         text-align: center;
       }
     }
   }

   .box-select-layer {
     position: absolute;
     left: 0;
     top: 0;
     border: 1px solid #3399ff;
     background-color: rgba(51, 153, 255, 0.28);
     z-index: 999;
     display: none;
   }
   .node-disabled {
      background-color: #fafafa;
      color: #cfd0d3;
   }
   .node-selected {
     // box-shadow: 0 0 8px #3399ff;
     // background-color: rgba(0, 0, 0, .2) !important;
     background: #DEE8F4;
     box-shadow: 1px 4px 6px 1px rgba(106,133,167,0.30);
     border-radius: 4px;
   }
 }

 .designer-menu {
   position: absolute;
   overflow: visible;
   padding: 6px 0;
   @include bg-color($light-base-color, $dark-workflow-bg-color);
   box-sizing: border-box;
   border-radius: 4px;
   box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.25);
   z-index: 900;

   .designer-menu-ul {
     min-width: 100px;

     .designer-menu-li {
       position: relative;
       padding: 0 10px;
       margin: 0;
       line-height: 25px;
       height: 25px;
       @include font-color($text-color, $dark-text-color);
       font-size: 12px;
       text-align: left;
       clear: both;
       white-space: nowrap;
       list-style: none;
       cursor: pointer;
       transition: background 0.2s ease-in-out;

       &:hover {
         @include bg-color( $hover-color, $dark-text-desc-color);
         .sub-menu-ul{
           display: block;
         }
       }
     }
   }
   .sub-menu-ul {
    position: absolute;
    transform: translateX(100%);
    top: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 0;
    display: none;
    @include bg-color($light-base-color, $dark-workflow-bg-color);
   }

   .designer-menu-li-icon {
     display: inline-block;
     vertical-align: middle;
     height: 16px;
     width: 16px;
     margin-top: -1px;
     @include font-color($text-color, $dark-text-color);
   }

   .designer-menu-li-text {
     margin-left: 10px;
     vertical-align: middle;
   }
 }
 .executor-pending {
   position: absolute;
   background: #fff;
   border: 2px solid #666;
   right: -30px;
   top: -37px;
   border-radius: 4px;
   padding: 3px;
 }
 .executor-pending:after, .executor-pending:before {
   top: 100%;
   left: 50%;
   border: solid transparent;
   content: " ";
   height: 0;
   width: 0;
   position: absolute;
   pointer-events: none;
 }

 .executor-pending:after {
   border-top-color: #fff;
   border-width: 7px;
   margin-left: -23px;
 }
 .executor-pending:before {
   border-top-color: #666;
   border-width: 10px;
   margin-left: -26px;
 }
 .executor-icon {
   position: absolute;
   right: 4px;
   top: 10px;
 }

 .executor-loading {
   animation: loading 2s linear 0s infinite ;
 }
 @keyframes loading {
   from {
     transform: rotateZ(0deg);
   } to {
       transform: rotateZ(360deg);
     }
 }
